<% if !@user.group %>
    <%= render "common/group_notice" %>
<% end %>
<div class="panel panel-primary">
    <div class="panel-heading"><%= @user.name %></div>
    <div class="panel-body">

    </div>
    <table class="table">
        <caption><%= "账单总结:" %></caption>
        <thead>
        <th>平均分摊</th>
        <th>个人总花费</th>
        <th>个人金额</th>
        <th>付款次数</th>
        </thead>
        <tbody>
        <tr>
            <td><%= @note.payment %></td>
            <td><%= @note.total %></td>
            <td><%= (@note.total - @note.payment).round(2) %></td>
            <td><%= @count %></td>
        </tr>
        </tbody>
    </table>
    <%= %>
</div>


<div class="panel panel-default">
    <div class="panel-body"></div>
    <ul id="myTab" class="nav nav-tabs">
        <li class="active">
            <a href="#mybills" data-toggle="tab">
                <%= "#{@user.name}的账单" %>
            </a>
        </li>
        <li>
            <a href="#joined_group" data-toggle="tab">
                加入的小组
            </a>
        </li>
    </ul>
    <div class="tab-content" id="table_contant">
        <div class="tab-pane fade in active" id="mybills">
            <% if @mybills.length != 0 %>
                <table class="table">
                    <!--<caption><%= @user.name %>的最近账单</caption>-->
                    <thead>
                    <th>付款人</th>
                    <th>描述</th>
                    <th>金额</th>
                    <th>创建时间</th>
                    <th>成员</th>
                    <th>操作</th>
                    </thead>
                    <tbody>
                    <% @mybills.each do |bill| %>
                        <tr>
                            <td><%= render "common/user_icon", user:bill.user %></td>
                            <td><%= bill.description %></td>
                            <td><%= bill.amount %></td>
                            <td><%= bill.created_time %></td>
                            <td>
                                <% one_bill_users(bill).each do |user| %>
                                    <span class="label label-info">
                                        <%= link_to user.name, user_path(user) %>
                                    </span>
                                <% end %>
                            </td>
                            <td>
                                <% if bill.user_id != current_user.id %>
                                    <%= link_to "edit", edit_bill_path(bill), class: "btn btn-primary btn-xs disabled" %>
                                <% else %>
                                    <%= link_to "edit", edit_bill_path(bill), class: "btn btn-primary btn-xs" %>
                                <% end %>
                            </td>
                        </tr>
                    <% end %>
                    </tbody>
                </table>
                <%= paginate @mybills, param_name: 'mypage' %>
            <% end %>
        </div>
        <div class="tab-pane fade" id="joined_group">
            <% if @user.group %>
                <%= render "groups/group_panel", group: @user.group, display: true %>
            <% else %>
                <div class="row">
                    <div class="col-md-6 col-md-offset-5">
                        <%= link_to "加入一个小组", groups_path %>
                    </div>
                    <div class="col-md-6 col-md-offset-5">
                        <%= link_to "创建一个小组", new_group_path %>
                    </div>
                </div>


            <% end %>
        </div>
    </div>

</div>

